package com.DongBing.common.utils;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.Data;

import java.io.Serializable;

@Data
@JsonIgnoreProperties(ignoreUnknown = true)
public class Res<T> implements Serializable {

    private int code;

    private String message;

    private T data;

    private Res(int code, String message, T data) {
        this.code = code;
        this.message = message;
        this.data = data;
    }

    public static <T> Res<T> success(String message){
        return new Res<>(200, message, null);
    }

    public static <T> Res<T> success(String message,T date){
        return new Res<>(200, message, date);
    }

    public static <T> Res<T> error(String message){
        return new Res<>(404, message, null);
    }

    public static <T> Res<T> error(String message,T date){
        return new Res<>(404, message, date);
    }

}
